/*
 * Copyright (c)  2015~2020, xforceplus
 * All rights reserved.
 * Project:datacare-orm
 * Id: PageQueryIgnoreTag.java   2020-10-10 21-14-27
 * Author: Evan
 */
package cn.datacare.orm.engine.tag;

import org.beetl.core.tag.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

import static cn.datacare.orm.query.PageQuery.PAGE_FLAG;
import static cn.datacare.orm.util.StringUtils.SPACE;

/**
 * <p>
 * Title:
 * </p>
 * <p>
 * Description:
 * </p>
 * <p>
 * Copyright: 2015~2020
 * </p>
 * <p>
 * Company/Department: xforceplus
 * </p>
 *
 * @author Evan
 * <b>Creation Time:</b> 2020-10-10 21-14-27
 * @since V1.0
 */
public class PageQueryIgnoreTag extends Tag {
    /**
     * 日志
     */
    private static final Logger logger = LoggerFactory.getLogger(PageQueryIgnoreTag.class);

    @Override
    public void render() {
        Object o = ctx.getGlobal(PAGE_FLAG);
        if (o != null && o == Boolean.TRUE) {
            try {
                this.bw.writeString(SPACE);
            } catch (IOException e) {
                logger.warn(e.getMessage(), e);
            }

        } else {
            this.doBodyRender();

        }
    }
}
